<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include/include :: header('修改消息基础')" />
    <th:block th:include="include/include :: datetimepicker-css" />
    <link rel="stylesheet" th:href="@{/css/summernote.css}" />
    <style>
        #receive-table tr {
            height: 35px;
        }
        #receive-table tr .receive-label {
            width: 15%;
            text-align: center;
        }
        #receive-table tr .receive-value {
            width: 85%;
        }
        .panel{
         	margin-bottom: 0;
		}
        label.error {
            position: relative;
            color: #ef392b;
            left: 0;
            top: 0;
            font-size: 12px;
            z-index:99;
        }
        #validate-result{
        	color: #ef392b;
        }
    </style>
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="editForm" th:action="@{/msg/messages}" th:object="${viewobject}">
            <input name="msgId" th:field="*{msgId}" type="hidden">
            <input type="hidden" name="oper" id="oper" th:value="${oper}"/>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">消息类型：</label>
                <div class="col-sm-8">
                    <select name="msgType" id="type" class="form-control" th:with="type=${@dict.getType('message_type')}">
                        <option th:each="dict : ${type}" th:text="${dict.label}" th:value="${dict.value}" th:field="*{msgType}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">消息标题：</label>
                <div class="col-sm-8">
                    <input name="msgTitle" th:field="*{msgTitle}" class="form-control" type="text" maxlength="40" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">消息内容：</label>
                <div class="col-sm-8">
                    <textarea id="msgContent" name="msgContent" th:field="*{msgContent}"></textarea>
                    <div id="validate-result"></div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">发送方式：</label>
                <div class="col-sm-8">
                    <div th:with="type=${@dict.getType('msg_channel')}">
                        <label th:each="dict : ${type}" class="check-box">
                            <input name="msgChannels" type="checkbox" th:value="${dict.value}" th:text="${dict.label}">
                        </label>
                    </div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">接收范围：</label>
                <div class="col-sm-8">
                    <div>
                        <label class="radio-box">
                            <input type="radio" th:field="*{receiveRange}" id="receiveRange" name="receiveRange" value="1" required/>部分
                        </label>
                        <label class="radio-box">
                            <input type="radio" th:field="*{receiveRange}" id="receiveRange2" name="receiveRange" value="2" required/>全部
                        </label>
                    </div>
                </div>
            </div>
            <div class="form-group" style="display: none">
                <div id="receive-object">
                    <label class="col-sm-3 control-label">接收对象：</label>
                    <div class="col-sm-8">
                        <input name="receiverObject" hidden="true" />
                        <table border="1"  cellspacing="0" cellpadding="0" style="width: 100%" id="receive-table">
                            <tr>
                                <td class="receive-label">部门&nbsp;<a href="javascript:void(0);" onclick="selectDept()">选择</a> </td>
                                <td class="receive-value" id="current-dept">未选择</td>
                                <td class="hidden" style="display: none" id="current-dept-rows"></td>
                            </tr>
                            <tr>
                                <td class="receive-label">角色&nbsp;<a href="javascript:void(0)" onclick="selectRole()">选择</a></td>
                                <td class="receive-value" id="current-role">未选择</td>
                                <td class="hidden" style="display: none" id="current-role-rows"></td>
                            </tr>
                            <tr>
                                <td class="receive-label">用户&nbsp;<a href="javascript:void(0)" onclick="selectUser()">选择</a></td>
                                <td class="receive-value" id="current-user">未选择</td>
                                <td class="hidden" style="display: none" id="current-user-rows"></td>
                            </tr>
                        </table>
                        <div id="validate-result-object"></div>
                    </div>
                </div>
            </div>
        </form>
        <div class="row" id="submit-area">
            <div class="col-sm-offset-5 col-sm-10">
                <button type="button" class="btn btn-sm btn-primary" onclick="submitHandler()"><i class="fa fa-check"></i>保 存</button>&nbsp;
                <button type="button" class="btn btn-sm btn-danger" onclick="closeItem()"><i class="fa fa-reply-all"></i>关 闭 </button>
            </div>
        </div>
    </div>
    <th:block th:include="include/include :: footer" />
    <th:block th:include="include/include :: datetimepicker-js" />
    <script th:src="@{/js/summernote.js}"></script>
    <script th:src="@{/js/summernote-zh-CN.js}"></script>
    <script th:src="@{/pages/msg/messages/messagesEdit.js}"></script>
    <script th:inline="javascript">
        /*<![CDATA[*/
        var message = [[${viewobject}]];
        /*]]>*/
        $(function() {
            //$.common.initFormInfo();
            $('#msgContent').summernote({
                lang : 'zh-CN',
                height: '300px'
            });
        });
    </script>
</body>
</html>